//
//  QQResult.m
//  test1
//
//  Created by gengzhangjia on 15/8/4.
//  Copyright (c) 2015年 gengzhangjia. All rights reserved.
//

#import "QQResult.h"

@implementation QQResult
+ (instancetype) success
{
    QQResult *result =[QQResult alloc];
    result.resultCode = QQResultCodeSuccess;
    result.errorInfo = @"分享成功";
    return result;
}

+ (instancetype) generalError
{
    QQResult *result = [QQResult alloc];
    result.resultCode = QQResultCodeEndFaild;
    result.errorInfo = @"分享错误";
    return result;
}

- (BOOL) isSuccess
{
    return _resultCode == QQResultCodeSuccess;
}

+ (instancetype) notInstallApp
{
    QQResult *result =[[QQResult alloc] init];
    result.resultCode =QQResultCodeNotInstall;
    result.errorInfo =@"没有安装微博客户端";
    
    return  result;
}

+ (instancetype) notError
{
    QQResult *result =[[QQResult alloc] init];
    result.resultCode =QQResultCodeNotInstall;
    result.errorInfo =@"未知错误";
    return  result;
}

+ (instancetype) createConditionWithErrorCode:(QQResultCode) resultCode
                                   resultInfo:(NSString *) resultInfo
{
    QQResult *result =[[QQResult alloc] init];
    result.resultCode =resultCode;
    result.errorInfo =resultInfo;
    
    return  result;
}

+ (instancetype) parseData:(QQBaseResp *) qqBaseResp
{
    QQResult *result = nil;
    if([qqBaseResp isKindOfClass:[SendMessageToQQResp class]])
    {
        SendMessageToQQResp* sendResp = (SendMessageToQQResp*)qqBaseResp;
        result = [[QQResult alloc] init];
        if ([sendResp.result isEqualToString:@"0"])
        {
            result = [QQResult success];
        }
        else
        {
            result = [QQResult generalError];
        }
    }
    return result;
}
@end
